<?php
// +----------------------------------------------------------------------
// | 贵州猿创科技 [致力于通过产品和服务，帮助创业者高效化开拓市场]
// +----------------------------------------------------------------------
// | Copyright(c)2019~2024 https://xhadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author:贵州猿创科技<416716328@qq.com>|<Tel:18786709420>
// +----------------------------------------------------------------------

namespace app\model;

use app\common\providers\UploadProviders;
use think\Model;


class App extends Model
{
    public function setImageAttr($value)
    {
        if (empty($value)) {
            return '';
        }
        return UploadProviders::path($value);
    }

    public function getImageAttr($value)
    {
        if (empty($value)) {
            return '';
        }
        return UploadProviders::url($value);
    }


    public function setTableDataAttr($value)
    {
        if (is_array($value)) {
            return json_encode($value, JSON_UNESCAPED_UNICODE);
        }
        return $value;
    }

    public function getTableDataAttr($value)
    {
        if (empty($value)) {
            return [];
        }
        $data = json_decode($value, true);
        if (is_array($data)) {
            return $data;
        }
        return [];
    }
}